package net.hn.hnms.biz.project.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.project.request.StandingBookManageReq;
import net.hn.hnms.biz.project.service.StandingBookManageService;
import net.hn.hnms.biz.project.vo.StandingBookManageVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "单项管理", tags = {"单项管理"})
@RestController
@RequestMapping("/standingbookmanage")
public class StandingBookManageController extends BaseController {

    @Autowired
    private StandingBookManageService standingBookManageService;

    /**
     * 项目基本信息列表
     */
    @ApiOperation("项目基本信息列表")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<StandingBookManageVo>> page(StandingBookManageReq standingBookManageReq, PageQuery pageQuery) {
        return R.ok(standingBookManageService.selectPageList(standingBookManageReq, pageQuery));
    }

    /**
     * 新增项目基本信息
     */
    @ApiOperation("新增单项管理")
    @SaCheckPermission("project:standingbookmanage:add")
    @PostMapping("/add")
    @Log(title = "新增单项管理", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody StandingBookManageReq standingBookManageReq) {
        return toAjax(standingBookManageService.insert(standingBookManageReq));
    }

    /**
     * 删除项目基本信息
     */
    @ApiOperation("删除单项管理")
    @SaCheckPermission("project:standingbookmanage:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @PostMapping("delete")
    @Log(title = "删除单项管理", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        standingBookManageService.updateDeleteByIds(idList);
        return R.ok();
    }

    /**
     * 更新项目基本信息
     */
    @ApiOperation("更新单项管理")
    @SaCheckPermission("project:standingbookmanage:update")
    @PostMapping("/update")
    @Log(title = "更新单项管理", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody StandingBookManageReq standingBookManageReq) {
        standingBookManageService.updateById(standingBookManageReq);
        return R.ok();
    }

    /**
     * 项目信息详情
     */
    @ApiOperation("项目信息详情")
    @GetMapping("/{id}")
    public R<StandingBookManageVo> detail(@PathVariable("id") String id) {
        return R.ok(standingBookManageService.selectDetailById(id));
    }

    /**
     * 项目基本信息列表
     */
    /*@ApiOperation("项目基本信息列表")
    @GetMapping("/getProjectList")
    public R<List<StandingBookManageVo>> getProjectList(StandingBookManageReq standingBookManageReq) {
        return R.ok(standingBookManageService.getProjectList(standingBookManageReq));
    }*/


    /**
     * 供应商基本信息列表
     */
    /* @ApiOperation("供应商基本信息列表")
    @GetMapping("/getSupplierInfo")
   public R<List<SupplierInfoVo>> getSupplierInfo(StandingBookManageReq standingBookManageReq) {
        return R.ok(standingBookManageService.getSupplierInfo(standingBookManageReq));
    }*/

    /**
     * 法人基本信息列表
     */
    /*@ApiOperation("法人基本信息列表")
    @GetMapping("/getLegalPerson")
    public R<List<LegalPerson>> getLegalPerson(StandingBookManageReq standingBookManageReq) {
        return R.ok(standingBookManageService.getLegalPerson(standingBookManageReq));
    }
*/


}
